<template>
  <div>
      <title-panel/>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 26%"><span style="color:#FF3B30;">*</span>记录日期</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.recordDate && list.recordDate.substring(0, 10) }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 36%"><span style="color:#FF3B30;">*</span>处理或死亡原因</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.dieType && list.dieType.name }}
        </div>
      </div>
    </van-cell>
    <van-cell>
      <div class="flex-between col-333333">
        <div class="m-r-10" style="width: 26%"><span style="color:#FF3B30;">*</span>处理方法</div>
        <div class="line-text-out text-right" style="width: 68%">
          {{ list.handleMethod && list.handleMethod.name }}
        </div>
      </div>
    </van-cell>
    <van-cell :border='false'>
      <div class="flex-between col-333333" @click='viewEarLabel'>
        <div class="m-r-10" style="width: 26%"><span style="color:#FF3B30;">*</span>处理数量 (只)</div>
        <div class="line-text-out text-right leaveNum" style="width: 68%; padding-right: 60px;">
          {{ list.handleCount }}
        </div>
      </div>
    </van-cell>
    <div class="m-b-10 shop">
      <div class="flex-between bottom content font-14 line-height-2">
        <div
          class="col-8686 text-center footerImg"
          @click="goCompile"
          style="width: 50%"
        >
          <img src="../../assets/img/bianji.png" alt="" />
          编辑
        </div>
        <div
          class="col-8686 text-center footerImg"
          @click="deleteContent"
          style="width: 50%"
        >
          <img src="../../assets/img/shanchu.png" alt="" />
          删除
        </div>
      </div>
    </div>
  </div>
</template>
<script>
import {
  Form,
  Field,
  Calendar,
  RadioGroup,
  Radio,
  Dialog,
  Toast,
  DatetimePicker,
  Picker,
  Button,
  Icon,
  Cell,
  Popup,
  Image
} from 'vant'
import dayjs from 'dayjs'
// import {
//   commonService,
//   buyProcessService,
//   standardizeService,
// } from "@/services";
import UploadImg from '@/components/uploadImg'
import TitlePanel from '@/components/titlePanel'
import { getValue, setValue, setObject, clearValue } from '@/utils/auth'
import { postHandle, getHandle } from '@/api'
export default {
  components: {
    UploadImg,
    TitlePanel,
    [Form.name]: Form,
    [Field.name]: Field,
    [Calendar.name]: Calendar,
    [RadioGroup.name]: RadioGroup,
    [Radio.name]: Radio,
    [Picker.name]: Picker,
    [DatetimePicker.name]: DatetimePicker,
    [Button.name]: Button,
    [Icon.name]: Icon,
    [Popup.name]: Popup,
    [Toast.name]: Toast,
    [Cell.name]: Cell,
    [Dialog.Component.name]: Dialog.Component,
    [Image.name]: Image,
    [Dialog.name]: Dialog
  },
  data() {
    return {
      list: [],
      imgs: '',
      fileInfoList: [],
      contentObj: {},
      flag: true,
      objGlobal: {
        id: '',
        loginUserId: '',
        tenantCode: '',
        productBatchId: '',
        token: ''
      }
    }
  },
  created() {
    this.getViewData()
    // this.$bridge.register(
    //   "getData",
    //   (loginUserId, tenantCode, token, productBatchId, id, loginName, type) => {
    //     // 请加上自己的事件列表事件
    //     this.objGlobal.productBatchId = productBatchId || "";
    //     this.objGlobal.id = id || "";
    //     this.objGlobal.loginName = loginName || "";
    //     this.objGlobal.tenantCode = tenantCode || "";
    //     this.objGlobal.loginUserId = loginUserId || "";
    //     setValue("allToken", token);
    //     this.initialize();
    //   }
    // );
  },
  mounted() {},
  methods: {
    // 查看耳标数据
    viewEarLabel() {
      setValue('seeRecordId2', getValue('dead-view-id'))
      // 跳转查看耳标公共vue页面
      this.$bridge.call('sheepSee')
    },
    // 查看页面数据请求
    getViewData() {
      getHandle(`/agri/api/yzbzh/dieHarmlesshandle/queryDetail/${getValue('dead-view-id')}`).then(res => {
        console.log(res)
        this.list = res.data
      })
    },
    getContent() {},
    goCompile() {
      // 跳转编辑之前需要清除缓存,防止上一次没有清除的缓存影响数据回显
      clearValue('earTag2')
      clearValue('editDead')
      this.$bridge.call('editDeadRecord')
    },
    initialize() {
      getHandle(
        `/ccyt/api/bzh/farmOperation/queryDetail/${this.objGlobal.id}?loginUserId=${this.objGlobal.loginUserId}&tenantCode=${this.objGlobal.tenantCode}`
      ).then((res) => {
        this.contentObj = res.data
        this.imgs = res.data.operationImgs
        this.fileInfoList = res.data.operationImgs.split(',')
      })
    },
    beforeClose(action, done) {
      if (action === 'confirm') {
        setTimeout(() => {
          postHandle(
            `/agri/api/yzbzh/dieHarmlesshandle/delete/${getValue('dead-view-id')}`
          ).then((res) => {
            if (res.status == '0') {
              this.$toast(res.msg)
              done()
              this.$bridge.call('base.closePage')
            } else {
              this.$toast(res.msg)
              done()
            }
          })
        }, 1000)
      } else {
        done()
      }
    },
    deleteContent() {
      Dialog.confirm({
        title: '提示',
        message: '确定要删除吗',
        beforeClose: this.beforeClose
      })
    }
  }
}
</script>
<style lang="scss" scoped>
  [data-v-2d70d870] .van-cell {
    border-bottom: none;
  }
.leaveNum{
  position: relative;
}
.leaveNum::after{
  content: "查看";
  position: absolute;
  font-size: 12px;
  top: 0;
  right: 0;
  width: 50px;
  height: 24px;
  text-align: center;
  border: 1px solid #37B5B5;
  color: #37B5B5;
  border-radius: 4px;
}
.van-cell {
  line-height: 40px;
}
.flex-between {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
  line-height: 2em;
}
.m-r-10 {
  margin-right: 10px;
}
.line-text-out {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.text-right {
  text-align: right;
}
.text-center {
  text-align: center;
}
.col-1b1b {
  color: #1b1b1b;
}
.col-8686 {
  color: #868686;
}
::v-deep .van-cell {
  border-bottom: 1px solid #dbd8d8;
}
.imgstyle::after {
  content: "";
  width: 100px;
}
.footerImg {
  display: flex;
  flex-direction: column;
  align-items: center;
  color: #37b5b5;
  > img {
    width: 22px;
    height: 22px;
  }
}
.shop .bottom {
  position: fixed;
  bottom: 0;
  height: 68px;
  width: 100%;
  box-sizing: border-box;
  background: #ffffff;
  padding: 8px 10px 8px 14px;
  box-shadow: 0px -2px 5px 0px rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.bthStyle {
  width: 56px;
  height: 20px;
  border-radius: 10px;
  border: 1px solid #2871fe;
}
.addbtn{
    width: 50px;
    height: 24px;
    font-size: 13px;
    padding: 0;
    margin-top: 2px;
}
</style>
